package com.boot.security.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.mffl.SysSms;

@Mapper
public interface SysSmsDao {

    @Select("select * from sys_sms t where t.id = #{id}")
    SysSms getById(Long id);

    @Select("select * from sys_sms t where t.phone = #{phone} ORDER BY sendtime DESC LIMIT 0,1")
    SysSms getByPhone(Long phone);

    @Delete("delete from sys_sms where id = #{id}")
    int delete(Long id);

    int update(SysSms sysSms);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into sys_sms(phone, code, context, status, result, sendtime) values(#{phone}, #{code}, #{context}, #{status}, #{result}, #{sendtime})")
    int save(SysSms sysSms);
    
    int count(@Param("params") Map<String, Object> params);

    List<SysSms> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
